package com.fcmeditech.AsianSexyGirls;

import java.util.ArrayList;

import com.fcmeditech.AsianSexyGirls.File.BitmapManager;
import android.app.ProgressDialog;
import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.ProgressBar;

public class Galleryadapter extends BaseAdapter{
	 private Context context;    
	 //private static LayoutInflater inflater=null;
	 private ArrayList<ImageObject> listimg;
	 ProgressDialog pDialog;
	 public static final int progress_bar_type = 0; 
	 ImageView image;
	 ProgressBar bar;
	 BitmapManager bmManager=new BitmapManager();
	 Gallery gallery;
	
	public Galleryadapter(Context c, ArrayList<ImageObject> listimg, Gallery gallery) {
		super();
		this.context = c;
		this.listimg = listimg;
		this.gallery=gallery;
	
	 
	}

	public int getCount() {
		// TODO Auto-generated method stub
		return listimg.size();
	}
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
	       ImageObject myImg= listimg.get(position);
	       ImageView img;
	if(convertView==null)
	{      img=new ImageView(this.context);
	       img.setLayoutParams(new Gallery.LayoutParams(gallery.getWidth(), gallery.getHeight()));
	       img.setPadding(30,0,30,0);
	}else img=(ImageView)convertView.getTag();
	       
		   bmManager.loadBitmap(myImg.getImgLink(), img ,img.getWidth(),img.getHeight(), position); //--->load bitmap from Cache 
	       Bitmap result=bmManager.getBitmapFromCache(myImg.getImgLink());
	       listimg.get(position).setmImage(result);
		   
	        return img;
		}

}